package com.training.java.module2;

public abstract class Question {

    private String question;

    public abstract boolean isCorrectAnswer();

    public static Question factory(String unparsedString){
        char typeOfQuestion = unparsedString.charAt(0);

        if(typeOfQuestion  == '-'){
            return new QuestionWithTextAnswer(unparsedString);
        }

        if(typeOfQuestion == '+'){
            return new QuestionWithAnswerVariants(unparsedString);
        }
        throw new RuntimeException(String.format("Incorrect type of question: %c",typeOfQuestion));
    }

    protected String getQuestion() {
        return question;
    }

    protected void setQuestion(String question){
        this.question = question;
    }


}
